const logger = (
  message: any,
  type: "info" | "warn" | "error" | "debug" | "table" | "trace" | "dir" = "info"
) => {
  if (process.env.NODE_ENV === "development") {
    switch (type) {
      case "info":
        console.info(message);
        break;
      case "warn":
        console.warn(message);
        break;
      case "error":
        console.error(message);
        break;
      case "debug":
        console.debug(message);
        break;
      case "table":
        console.table(message);
        break;
      case "trace":
        console.trace(message);
        break;
      case "dir":
        console.dir(message);
        break;
      default:
        break;
    }
  }
};

logger.info = (message: any) => {
  logger(message, "info");
};
logger.warn = (message: any) => {
  logger(message, "warn");
};
logger.error = (message: any) => {
  logger(message, "error");
};
logger.debug = (message: any) => {
  logger(message, "debug");
};
logger.table = (message: any) => {
  logger(message, "table");
};
logger.trace = (message: any) => {
  logger(message, "trace");
};
logger.dir = (message: any) => {
  logger(message, "dir");
};

export const inject = () => {
  window.$log = logger;
};

export default logger;
